package com.hy.erp.inventory.pojo;

import java.io.Serializable ;
import java.math.BigDecimal ;
import java.util.Date;
import java.util.List ;

import javax.persistence.CascadeType ;
import javax.persistence.Column ;
import javax.persistence.Entity ;
import javax.persistence.FetchType ;
import javax.persistence.Id ;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany ;
import javax.persistence.OneToOne ;
import javax.persistence.PrimaryKeyJoinColumn ;
import javax.persistence.Table ;
import javax.persistence.Temporal ;
import javax.persistence.TemporalType ;

import org.hibernate.annotations.Index ;


import com.hy.erp.inventory.pojo.interfaces.IMembereRelation;
import com.hy.erp.inventory.pojo.interfaces.IOrganisation;
import com.hy.erp.inventory.pojo.interfaces.IPositon;
import com.hy.erp.inventory.pojo.interfaces.IPositonType;
import com.hy.mydesktop.shared.persistence.domain.gxt.MyBaseModel;


/**
 * <ul>
 * <li>开发作者：汤莉</li>
 * <li>设计日期：2010-10-6；时间：下午01:31:45</li>
 * <li>字段类型：long；字段名称：serialVersionUID</li>
 * <li>设计目的：</li>
 * </ul>
 * <ul>
 * <b>修订编号：</b>
 * <li>修订日期：</li>
 * <li>修订作者：</li>
 * <li>修订原因：</li>
 * <li>修订内容：</li>
 * </ul>
 */
@Entity
//@Name("positon")
//@Scope(ScopeType.SESSION)
@Table(name="t_position")
public class Positon extends MyBaseModel //implements IPositonType
					
{

	private static final long	serialVersionUID	=
														- 95352565685769861L ;

	/**
	 * 构造函数
	 */
	public Positon(){}

	

	//#####################################################################3
	

//	@OneToOne(targetEntity=Positon.class,cascade=CascadeType.ALL,fetch=FetchType.LAZY)
	@ManyToOne(fetch=FetchType.EAGER)
	//@PrimaryKeyJoinColumn
	@JoinColumn(name="positionType_identifier")

	public PositionType getPositonType ( )
	{
		return this.get(IPositon.POSITONTYPE) ;
	}

	@Column(name="startDate",unique=false,nullable=true,insertable=true,updatable=true)
	@Temporal(TemporalType.DATE)
	public Date getStartDate ( )
	{
		return this.get(IPositon.STARTDATE) ;
	}

	@Column(name="stopDate",unique=false,nullable=true,insertable=true,updatable=true)
	@Temporal(TemporalType.DATE)
	public Date getStopDate ( )
	{
		return this.get(IPositon.STOPDATE) ;
	}

	@Column(name="wages",unique=false,nullable=true,insertable=true,updatable=true)
	public BigDecimal getWages ( )
	{
		return this.get(IPositon.WAGES) ;
	}

	
	
	
	/*@OneToMany(targetEntity=Organisation.class,cascade=CascadeType.ALL,fetch=FetchType.LAZY)
	public List < IOrganisation > getOrganisation ( )
	{
		return this.get(IPositon.ORGANISATION) ;
	}*/

	
	

	//#####################################################################3
	
	public void setPositonType (
									PositionType positonType )
	{
		super.set(IPositon.POSITONTYPE,positonType) ;
		super.set(IPositon.POSITONTYPE_FOR_SHOW, positonType.getName());

	}

	public void setStartDate (
								Date startDate )
	{
		super.set(IPositon.STARTDATE,startDate) ;
	}

	public void setStopDate (
								Date stopDate )
	{
		super.set(IPositon.STOPDATE,stopDate) ;
	}

	public void setWages (
							BigDecimal wages )
	{
		super.set(IPositon.WAGES,wages) ;
	}

	
	/*public void setOrganisation (
							List < Organisation > organisation )
	{
		super.set(IPositon.ORGANISATION,organisation) ;
	}*/
	
//	//职位性质PositionProperty
//	@OneToOne(targetEntity=PositionProperty.class,cascade=CascadeType.ALL,fetch=FetchType.LAZY)
//	public PositonType getPositionProperty ( )
//	{
//		return this.get(IPositon.POSITIONPROPERTY) ;
//	}
//	public void setPositionProperty (
//	 							PositionProperty property )
// 	{
// 		super.set(IPositon.POSITIONPROPERTY,property) ;
// 	}
	
	@Column(name="positionName",unique=false,nullable=true,insertable=true,updatable=true)
	public String getPositionName()
	{
		return this.get(IPositon.POSITONNAME) ;
	}
	public void setPositionName(String name)
	{
		 super.set(IPositon.POSITONNAME,name) ;
			super.set(IPositonType.NAME, name);

	}
	
	public String getName ( )
	{
		return this.get(IPositonType.NAME) ;
	}

	public void setName(String name) {
		super.set(IPositonType.NAME, name);
	}
	
	public String getPositionTypeForShow ()
	{
		if (this.getPositonType().getName()==null) {
			
			return this.getPositonType().getName();
		} else {
			return this.get(IPositon.POSITONTYPE_FOR_SHOW) ;

		}
	}

	public void setPositionTypeForShow(String positionTypeForShow) {
		if (positionTypeForShow==null) {
			
			super.set(IPositon.POSITONTYPE_FOR_SHOW, positionTypeForShow);
		}else {
			
			super.set(IPositon.POSITONTYPE_FOR_SHOW, this.getPositonType().getName());
		}
	}
	
	
}
